<html>
<head><meta charset="utf-8"><title>Non-ASCII output in `Display` and `Debug` impls from std? · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html">Non-ASCII output in `Display` and `Debug` impls from std?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="207013400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207013400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Kalbertodt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207013400">(Aug 15 2020 at 09:23)</a>:</h4>
<p>Hey everyone. Two weeks ago <a href="https://github.com/rust-lang/rust/pull/75065">this PR</a> popped up, which changed the "µs" in the <code>Debug</code> impl of <code>Duration</code> to "us".  Some people are strongly against removing the non-ASCII unicode char (as µs is correct) while others are strongly in favor of keeping the output ASCII only to maximize compatibility.</p>
<p>In the PR, someone brought up that there should be a <strong>general decision</strong> on the use of non-ASCII chars in the standard library's <code>Debug</code> and <code>Display</code> impls. I agree with that, hence this thread. (Just to be clear: we are not talking about cases where non-ASCII unicode data already exists, like with <code>String</code>. This is just about the cases where non-ASCII chars are "hardcoded" in std.)</p>
<p>What do you think? Also: should we discuss this in an issue with FCP in the end?</p>



<a name="207013588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207013588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Kalbertodt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207013588">(Aug 15 2020 at 09:28)</a>:</h4>
<p>My personal opinion is that I would prefer using non-ASCII chars if they give an advantage (which they do in the µs case). Rust already has a strong opinion about all strings being UTF8 and the whole standard library is designed to work well with Unicode. I think it would be a bad step to disallow non-ASCII chars. <br>
Additionally, in the <code>Debug</code> case, users cannot assume anything about the output anyway. It is explicitly unstable.</p>



<a name="207018325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207018325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207018325">(Aug 15 2020 at 11:48)</a>:</h4>
<p>I like that Rust uses the whole range of character available and not just ASCII</p>



<a name="207018394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207018394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207018394">(Aug 15 2020 at 11:51)</a>:</h4>
<p>I don’t have a strong opinion either way though, but it’s nice that the idea of correctness extends to little details like those</p>



<a name="207020020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207020020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207020020">(Aug 15 2020 at 12:34)</a>:</h4>
<p>I don’t think we can decide this just in the context of μs vs us. Without any concept of locale I think sticking to ASCII for standard implementations of <code>std::fmt</code> traits is fair. It would be a really unfortunate restriction though, but I think we need better (any) globalization support to base this off</p>



<a name="207020709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207020709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> DPC <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207020709">(Aug 15 2020 at 12:52)</a>:</h4>
<p>markd it as S-waiting-on-team till we decide on what to do about it</p>



<a name="207023214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207023214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Kalbertodt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207023214">(Aug 15 2020 at 14:00)</a>:</h4>
<p>I'm not sure about the "get system locale and decide based on that". I think I'm against having the output of <code>Display</code> and <code>Debug</code> being based on the environment. I don't think we do that anywhere yet and it's probably unexpected to many. Additionally, if we read the locale, we should also use the correct fractional separator for the given local when formatting floats. But that would be a breaking change and meh. Also: the output of <code>Display</code> or <code>Debug</code> might not be intended for the machine the program is running on.</p>



<a name="207024638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207024638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pickfire <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207024638">(Aug 15 2020 at 14:40)</a>:</h4>
<p>I would say it depends, I rather see all kinds of different variety are included in the documentation, sometimes we even want to test and showcase non-ascii characters support such that I had see like chinese characters in the docs to check for edge cases. But I don't have much opinion on <code>us</code> vs <code>µs</code> since normally I forgot what is that and need to lookup the numbers online, but I would say in this case <code>us</code> may be better since it is also used for <code>cargo bench</code>.</p>



<a name="207026515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207026515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207026515">(Aug 15 2020 at 15:33)</a>:</h4>
<p>Given that strings will blindly write utf-8 already, as mentioned, it seems like an artificial limitation to only allow ASCII elsewhere.</p>



<a name="207027466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207027466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207027466">(Aug 15 2020 at 16:00)</a>:</h4>
<blockquote>
<p>I'm not sure about the "get system locale and decide based on that".</p>
</blockquote>
<p>That's not possible since this is in libcore, which can't depend on the OS.</p>



<a name="207028735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207028735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Kalbertodt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207028735">(Aug 15 2020 at 16:32)</a>:</h4>
<blockquote>
<p>That's not possible since this is in libcore, which can't depend on the OS.</p>
</blockquote>
<p>Good point.</p>



<a name="207034886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207034886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207034886">(Aug 15 2020 at 19:13)</a>:</h4>
<p><span class="user-mention silent" data-user-id="307289">Poliorcetics</span> <a href="#narrow/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F/near/207018325">said</a>:</p>
<blockquote>
<p>I like that Rust uses the whole range of character available and not just ASCII</p>
</blockquote>
<p>I like that Rust <em>supports</em> the whole range of characters available; there's a difference between that and forcing the use of them.</p>



<a name="207034952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207034952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207034952">(Aug 15 2020 at 19:14)</a>:</h4>
<p><span class="user-mention silent" data-user-id="138448">cuviper</span> <a href="#narrow/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F/near/207026515">said</a>:</p>
<blockquote>
<p>Given that strings will blindly write utf-8 already, as mentioned, it seems like an artificial limitation to only allow ASCII elsewhere.</p>
</blockquote>
<p>Strings will pass through non-ASCII if you already have it, but they won't introduce it if you don't. If the user's <em>data</em> uses UTF-8, then it's the user's responsibility to make sure that works.</p>



<a name="207034956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207034956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207034956">(Aug 15 2020 at 19:14)</a>:</h4>
<p>The issue here is not "should Rust handle Unicode", for which the answer is of course <em>yes</em>.</p>



<a name="207034973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207034973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207034973">(Aug 15 2020 at 19:15)</a>:</h4>
<p>The issue is "should Rust force-output Unicode on all systems, even if all the user's data is ASCII".</p>



<a name="207035029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207035029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207035029">(Aug 15 2020 at 19:16)</a>:</h4>
<p>To the best of my knowledge, there is <em>no</em> implementation of Display or Debug in the standard library that produces Unicode inherently, even if your data is ASCII.</p>



<a name="207035032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207035032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207035032">(Aug 15 2020 at 19:16)</a>:</h4>
<p>Except for this one.</p>



<a name="207035057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207035057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207035057">(Aug 15 2020 at 19:17)</a>:</h4>
<p>In the pull request, I cited <a href="https://en.wikipedia.org/wiki/Robustness_principle">https://en.wikipedia.org/wiki/Robustness_principle</a> . I think it'd be entirely appropriate for Rust to always support full UTF-8 Unicode, and for it never to <em>introduce</em> non-ASCII into otherwise ASCII data.</p>



<a name="207035229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207035229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207035229">(Aug 15 2020 at 19:21)</a>:</h4>
<p>I don't think we need to settle a "shall we ban non-ASCII in output from std for all time" question <em>right here and now</em>. I think it would suffice to say "for this particular use of a non-ASCII character, it isn't worth the compatibility issues".</p>



<a name="207035285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207035285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207035285">(Aug 15 2020 at 19:22)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F/near/207034973">said</a>:</p>
<blockquote>
<p>The issue is "should Rust force-output Unicode on all systems, even if all the user's data is ASCII".</p>
</blockquote>
<p>I guess my question is what's the downside of outputting utf-8?</p>



<a name="207035287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207035287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207035287">(Aug 15 2020 at 19:22)</a>:</h4>
<p>are there systems where it could cause an issue?</p>



<a name="207035290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207035290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207035290">(Aug 15 2020 at 19:22)</a>:</h4>
<p>Then, in the future, if someone has a specific reason to <em>introduce</em> non-ASCII into otherwise ASCII data, we could evaluate and determine how important it is.</p>



<a name="207035296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207035296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207035296">(Aug 15 2020 at 19:23)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> Yes, many. Not just ancient systems, but <em>current</em> systems.</p>



<a name="207035313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207035313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207035313">(Aug 15 2020 at 19:23)</a>:</h4>
<p>such as?</p>



<a name="207035357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207035357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207035357">(Aug 15 2020 at 19:24)</a>:</h4>
<p>A few examples:</p>
<ul>
<li>Some serial terminals on servers.</li>
<li>The stock Linux console, which understands UTF-8 but can't actually display Unicode characters because it doesn't have a font to do so.</li>
</ul>



<a name="207035382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207035382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207035382">(Aug 15 2020 at 19:25)</a>:</h4>
<p>If this were "some ancient systems Rust doesn't run on anyway", I wouldn't be arguing for it. This is "real situations that arise in 2020 on modern OSes, that aren't trivially fixed".</p>



<a name="207037235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207037235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207037235">(Aug 15 2020 at 20:10)</a>:</h4>
<p>stock windows console also likely cannot display it.</p>



<a name="207038166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207038166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Denton <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207038166">(Aug 15 2020 at 20:34)</a>:</h4>
<p>Stock Windows console can. The only issue would be unprintables or characters made of multiple UTF-16 code units when not using a CJK locale.</p>



<a name="207044076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207044076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207044076">(Aug 15 2020 at 23:09)</a>:</h4>
<blockquote>
<blockquote>
<p>I'm not sure about the "get system locale and decide based on that".</p>
</blockquote>
<p>That's not possible since this is in libcore, which can't depend on the OS.</p>
</blockquote>
<p>I can imagine globalization hooks available to <code>core::fmt</code> that didn’t depend on there being an OS underneath but provided the decimal separator, UTF8 support and other locale-specific things to be filled in later. But we don’t have any of that yet, and until we do I think not introducing non-ASCII in std formats is ok.</p>



<a name="207050787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207050787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207050787">(Aug 16 2020 at 02:35)</a>:</h4>
<blockquote>
<p>I think we need better (any) globalization support to base this off</p>
</blockquote>
<p>I'll note that the case in question isn't really a globalization issue.  <code>µs</code> is correct SI everywhere, not something that's only appropriate for a subset of cultures.</p>
<p>(If the issue was currency symbols, for example, the conversation would be very different.)</p>



<a name="207051551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207051551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207051551">(Aug 16 2020 at 02:58)</a>:</h4>
<p>Ah yes, I guess I’m conflating explicit UTF8 support with locale since it seems like OSes tend to do that</p>



<a name="207066873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207066873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207066873">(Aug 16 2020 at 11:14)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F/near/207035382">said</a>:</p>
<blockquote>
<p>If this were "some ancient systems Rust doesn't run on anyway", I wouldn't be arguing for it. This is "real situations that arise in 2020 on modern OSes, that aren't trivially fixed".</p>
</blockquote>
<p>the world is a sad place :(</p>



<a name="207304054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207304054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207304054">(Aug 18 2020 at 19:26)</a>:</h4>
<p>incidentally, I just noticed that criterion outputs microseconds as <code>us</code></p>



<a name="207319828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207319828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim McNamara <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207319828">(Aug 18 2020 at 21:39)</a>:</h4>
<p>I wonder if the compiler target could specify UTF8 support</p>



<a name="207319914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207319914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207319914">(Aug 18 2020 at 21:40)</a>:</h4>
<p>as if you're putting <code>TERM</code> in the target?</p>



<a name="207319979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207319979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim McNamara <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207319979">(Aug 18 2020 at 21:41)</a>:</h4>
<p>I suppose so. Although supporting <code>TERM</code> could be a middle-ground.</p>



<a name="207346943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207346943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207346943">(Aug 18 2020 at 21:52)</a>:</h4>
<p>I said earlier in this thread I liked the way things are right now (and I like SI being respected) but I have been convinced that a programming language like Rust does not exist only for utf8/Unicode aware systems (I’m probably spoilt by my environnement for this)</p>



<a name="207763116"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207763116" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207763116">(Aug 23 2020 at 08:49)</a>:</h4>
<p>I went into further detail on GitHub but USASCII can get mangled on Windows OS with certain language supports, and the stock Linux console can support UTF-8, and does support it for Latin-1 characters (which includes μ) (and has for a while now). "A given configuration of things can mangle 1 or 2 characters" cuts against all possible text encodings, including USASCII, including far more common outputs from the compiler.</p>
<p>So what is best to choose becomes a matter of tradeoffs, percentages, and probabilities, rather than sure bets ever.</p>



<a name="207768319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207768319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207768319">(Aug 23 2020 at 11:19)</a>:</h4>
<p>I'm personally tending towards just using <code>us</code> for all the reasons stated in the thread.</p>



<a name="207768675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207768675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207768675">(Aug 23 2020 at 11:29)</a>:</h4>
<blockquote>
<p>The presumption that "we can always use 7-bit ASCII and not have it mangled" is incorrect.</p>
</blockquote>
<p>is a twist I wasn’t expecting.</p>



<a name="207776511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207776511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207776511">(Aug 23 2020 at 14:43)</a>:</h4>
<p>Oh yeah, I do seem to recall that in japanese fonts the <code>\</code> is usually a Yen symbol, so file paths in the command prompt always look, uh, "strange" you might say.</p>



<a name="207778140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207778140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Denton <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207778140">(Aug 23 2020 at 15:27)</a>:</h4>
<p>IIRC you can see this in other locales by setting the font to <code>MS Gothic</code>. Note that <a href="https://en.wikipedia.org/wiki/Code_page_932_(Microsoft_Windows)">code page 932</a> actually does map the value <code>0x5c</code> to <code>\</code> but for historic reasons (i.e. compatibility with <a href="https://en.wikipedia.org/wiki/JIS_C_6220">JIS C 6220</a>) fonts are allowed to display a localized character instead (also technically true of <code>~</code> but, unlike <code>\</code>, that isn't a special Windows character). However, this should be less of an issue now that the Windows console is placing a greater emphasis on Unicode and Unicode fonts. Though I guess that Microsoft may be reluctant to change the defaults due to backwards compatibility concerns. I think their new terminal application has better defaults (though this is installed separately).</p>



<a name="207797089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Non-ASCII%20output%20in%20%60Display%60%20and%20%60Debug%60%20impls%20from%20std%3F/near/207797089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Non-ASCII.20output.20in.20.60Display.60.20and.20.60Debug.60.20impls.20from.20std.3F.html#207797089">(Aug 23 2020 at 23:46)</a>:</h4>
<p>MS Office in most versions has options to manipulate how the backslash gets rendered because with the full support installed (basically necessary to get actual work done with the language) it leaks into everything. It's been a bit since I touched it, but I still see new issues discussing things related to that when I search... <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>
<p>Yeah, part of the issue is that a lot of the question here is "this falls down on some very niche interop cases" but the interop cases fall down even harder if the receiver is not also USASCII respecting and conflicts <em>do</em> exist in the USASCII range between UTF-8 and other font encodings, including on characters that actually have programmatic meaning in Rust. "Hedge on USASCII" with "us" in reality <em>is</em> hedging on UTF-8 <strong>plus</strong> the implicit USASCII cultural context, which we have but not everyone will, whereas "μs" is SI, it's far easier to search.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>